#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define pb push_back
#define mp make_pair
long long t;
long long n, m, lt, v;
long long x[100010];
long long y[100010];
long long a[100010];
long long b[100010];
long long l[100010];
long long r[100010];
pair<long long, long long> k[100010];
bool cmp(pair<long long, long long> a, pair<long long, long long> b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}
signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    while (t--)
    {
        cin >> n >> m >> lt >> v;
        for (long long i = 1; i <= n; i++)
        {
            cin >> x[i] >> y[i] >> a[i];
        }
        for (long long i = 1; i <= m; i++)
        {
            cin >> b[i];
        }
        long long z1 = 0;
        vector<long long> t1;
        for (long long i = 1; i <= n; i++)
        {
            if (a[i] < 0)
            {
                long long ll = lower_bound(b + 1, b + m + 1, x[i]) - b;
                if (b[ll] < x[i] || ll > m)
                    continue;
                long long tt = y[i] * y[i] + 2 * a[i] * (b[ll] - x[i]);
                if (tt > v * v)
                {
                    z1++;
                    t1.pb(i);
                }
            }
            else if (a[i] == 0)
            {
                if (b[m] >= x[i] && y[i] > v)
                {
                    z1++;
                    t1.pb(i);
                }
            }
            else
            {
                if (b[m] < x[i])
                    continue;
                long long tt = y[i] * y[i] + 2 * a[i] * (b[m] - x[i]);
                if (tt > v * v)
                {
                    z1++;
                    t1.pb(i);
                }
                // z1++;
            }
        }
        cout << z1 << " ";
        long long c = 0;
        for (long long i = 0; i < t1.size(); i++)
        {
            long long tx = t1[i];
            if (a[tx] > 0)
            {
                double p = x[tx];
                if (y[tx] > v)
                {
                    long long tt = lower_bound(b + 1, b + m + 1, p) - b;
                    p = b[tt];
                }
                else
                {
                    p += (v * v - y[tx] * y[tx]) / 2.0 / a[tx];
                    // cout << p << "\n";
                    long long tt = upper_bound(b + 1, b + m + 1, p) - b;
                    p = b[tt];
                }
                l[++c] = p;
                r[c] = b[m];
            }
            else if (a[tx] == 0)
            {
                long long tt = lower_bound(b + 1, b + m + 1, x[tx]) - b;
                l[++c] = b[tt];
                r[c] = b[m];
            }
            else
            {
                double p = x[tx];
                long long tt = lower_bound(b + 1, b + m + 1, p) - b;
                l[++c] = b[tt];
                // cout << p << " ";
                p += (v * v - y[tx] * y[tx]) / 2.0 / a[tx];
                // cout << p << "\n";
                tt = lower_bound(b + 1, b + m + 1, p) - b;
                // cout << p << "\n";
                tt--;
                r[c] = b[tt];
            }
        }
        // cout << "\n";
        for (long long i = 1; i <= c; i++)
        {
            k[i] = mp(l[i], r[i]);
            // cout << l[i] << " " << r[i] << "\n";
        }
        // cout << "\n";
        sort(k + 1, k + c + 1, cmp);
        long long ans = 0;
        long long z2 = 0, ty = 0;
        for (long long i = 1; i <= c; i++)
        {
            // cout << k[i].first << " " << k[i].second << "\n";
            if (ty >= k[i].first && ty <= k[i].second)
            {
            }
            else
            {
                z2++;
                ty = k[i].second;
            }
        }

        ans = max(ans, m - z2);
        z2 = 0, ty = 0;
        for (long long i = 1; i <= c; i++)
        {
            // cout << k[i].first << " " << k[i].second << "\n";
            if (ty >= k[i].first && ty <= k[i].second)
            {
            }
            else
            {
                z2++;
                ty = k[i].first;
            }
        }
        ans = max(ans, m - z2);
        sort(k + 1, k + c + 1);
        z2 = 0;
        ty = 0;
        for (long long i = 1; i <= c; i++)
        {
            // cout << k[i].first << " " << k[i].second << "\n";
            if (ty >= k[i].first && ty <= k[i].second)
            {
            }
            else
            {
                z2++;
                ty = k[i].first;
            }
        }
        ans = max(ans, m - z2);
        z2 = 0, ty = 0;
        for (long long i = 1; i <= c; i++)
        {
            // cout << k[i].first << " " << k[i].second << "\n";
            if (ty >= k[i].first && ty <= k[i].second)
            {
            }
            else
            {
                z2++;
                ty = k[i].second;
            }
        }
        ans = max(ans, m - z2);
        cout << ans << "\n";
    }
    return 0;
}